package application;

import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.stage.Stage;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;

public class Main extends Application {
	public Parent createContent() {
		final int ITEMS = 3;
		String IMAGE_48 = "icon-48x48.png";
		String IMAGE_68 = "icon-68x68.png";
		String IMAGE_88 = "icon-88x88.png";
		Image ICON_48 = new Image(getClass().getResourceAsStream(IMAGE_48));
		Image ICON_68 = new Image(getClass().getResourceAsStream(IMAGE_68));
		Image ICON_88 = new Image(getClass().getResourceAsStream(IMAGE_88));
		FlowPane flowPane = new FlowPane(Orientation.HORIZONTAL, 4, 2);
		flowPane.setPrefWrapLength(240); // preferred wraplength

		ImageView[] imageViews48 = new ImageView[ITEMS];
		ImageView[] imageViews482 = new ImageView[ITEMS];
		ImageView[] imageViews68 = new ImageView[ITEMS];
		ImageView[] imageViews682 = new ImageView[ITEMS];
		ImageView[] imageViews88 = new ImageView[ITEMS];
		ImageView[] imageViews882 = new ImageView[ITEMS];

		for (int i = 0; i < ITEMS; i++) {
			imageViews48[i] = new ImageView(ICON_48);
			imageViews482[i] = new ImageView(ICON_48);
			imageViews68[i] = new ImageView(ICON_68);
			imageViews682[i] = new ImageView(ICON_68);
			imageViews88[i] = new ImageView(ICON_88);
			imageViews882[i] = new ImageView(ICON_88);
			flowPane.getChildren().addAll(imageViews48[i],imageViews482[i],imageViews68[i],imageViews682[i], imageViews88[i], imageViews882[i]);
		}
		flowPane.setPrefSize(1024, 768);
		return flowPane;
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		primaryStage.setScene(new Scene(createContent()));
		primaryStage.setTitle("FlowPane");
		primaryStage.show();
	}

	/**
	 * Java main for when running without JavaFX launcher
	 */
	public static void main(String[] args) {
		launch(args);
	}
}
